home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!rpl
- From: rpl@netcom.com (Robert Laudati)
- Subject: Output precision
- Message-ID: <rplDLKLwK.119@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- X-Newsreader: TIN [version 1.2 PL1]
- Date: Mon, 22 Jan 1996 06:55:32 GMT
- Sender: rpl@netcom11.netcom.com
-
- It doesn't get too much more basic than this, but I can not
- set the precision correctly on output. Here's the sample:
-
- #include <stdio.h>
- #include <iostream.h>
- #include <iomanip.h>
-
- int main( int argc, char *argv[])
- {
- int i=0;
- float x=56.0;
- double y=34.038383999;
-
- i = cout.precision(6);
- printf( "%d %f %lf\n\n", i, x, y );
- cout << i << " " << x << " " << y << endl;
- return 0;
- }
-
- Which results in:
-
- robl@cosmo<216>: test
- 6 56.000000 34.038384
-
- 6 56 34.0384
- robl@cosmo<217>:
-
- I'm running gcc 2.7.1 on Solaris 2.4 - and very confused!
-
-
- Rob
- --
- .........................................................
- . Robert P. Laudati rob_laudati@trimble.com .
- . Trimble Navigation Ltd. rpl@netcom.com .
- . P.O. Box 3642 (408) 481-8292 voice .
- . Sunnyvale, CA 94088 (408) 481-8370 fax .
- . .
- . These views are not necessarily those of Trimble. .
- .........................................................
-